<div class="page-header settingheading">
  <h4>News Feed Settings</h4>
</div>
<?php echo form_open(null, 'id="form" class="form-horizontal"'); ?>
	<table class="table table-condensed" id="newsfeed_table">
		<thead>
			<tr>
				<th>News Name</th>
				<th>News Url</th>
				<th>News Status</th>
				<th>Action</th>
			</tr>
		</thead>
		<?php $row = 0; ?>
        <?php foreach($zapnewsfeed as $newsfeed){ ?>
		<tbody id="row<?php echo $row; ?>">
			<tr>
				<td>
					<input type="text" class="form-control" value="<?=$newsfeed['news_name']?>" name="newsfeed[<?php echo $row; ?>][news_name]" />
				</td>
				<td>
					<input type="text" class="form-control" value="<?=$newsfeed['news_url']?>" name="newsfeed[<?php echo $row; ?>][news_url]" />
				</td>
				<td>
					<?php 
					if (isset($zapnewsfeed[$row]['news_status']) && $zapnewsfeed[$row]['news_status']==1)
					{
						$checked="checked='checked'";
					}
					else
					{
						$checked='';
					}
					?>
					<input name="newsfeed[<?=$row?>][news_status]" class="switch" data-on-label="Show" data-off-label="Hide" type="checkbox" value="1" <?=$checked?>>
				</td>
				<td><a onclick="$('#row<?php echo $row; ?>').remove();" class="btn btn-danger">Remove</a></td>
			</tr>
		</tbody>
		<?php $row++; ?>
        <?php } ?>
	</table>
	<div class="alert alert-zap text-right">
		<button type="button" class="btn btn-primary btn-xs" onclick="addrow();">Add URL</button>
		<button type="submit" class="btn btn-primary btn-xs">Update</button>
	</div>
<?php echo form_close(); ?>
<script type="text/javascript"><!--
var row = <?php echo $row; ?>;

function addrow() {	
	html  = '<tbody id="row' + row + '">';
	html += '  <tr>';
	html += '    <td><input type="text" class="form-control" name="newsfeed[' + row + '][news_name]"></td>';
	html += '    <td><input type="text" class="form-control" name="newsfeed[' + row + '][news_url]"/></td>';
	html += '    <td><input name="newsfeed[' + row + '][news_status]" class="switch" data-on-label="Show" data-off-label="Hide" type="checkbox" value="1"></td>';
	html += '    <td><a onclick="$(\'#row' + row + '\').remove();" class="btn btn-danger">Remove</a></td>';
	html += '  </tr>';
	html += '</tbody>';
	
	$('#newsfeed_table').append(html);
	$('#row' + row ).find('.switch').bootstrapSwitch();
	
	row++;
}
//--></script>		